package com.honey.mybatis.generator.dao;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Clazz;
import com.honey.core.compiler.CompilationException;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.dbmapping.structure.Schema;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.mybatis.generator.AbstractClass;
import com.honey.mybatis.generator.MybatisPlugin;

public class DaoImplements extends AbstractClass {
	
	private String entity = null;
	private Schema schema = null; 
	public DaoImplements(MybatisPlugin belongPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(belongPlugin, introspectSchema, introspectSchemaColumn);
		schema = introspectSchema.getSchema();
		entity = getClassName( schema, mybatisPlugin.getEntityClassSuffix());
		
	}

	/* (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractClass#getAbstractJavaCompilation()
	 */
	@Override
	protected AbstractJavaCompilation getAbstractJavaCompilation()
			throws CompilationException {
		Clazz answer = null;
		try {
			answer =new Clazz(super.getImplementsClassType(schema,"<E extends "+entity+">"));
			answer.addSuperInterface(super.getInterfaceClassType(schema, "<"+entity+">"));
			answer.addImportedType(super.getEntityPrimitiveClassType(schema));
			answer.addImportedType(super.getModelPrimitiveClassType(schema));
		} catch (CompilationException e) {
			e.printStackTrace();
		}
		
		return answer;
	}
	
	@Override
	protected FullyQualifiedJavaType getType() {
		
		return null;
	}

	@Override
	protected FullyQualifiedJavaType getSuperClass() {
		
		return super.getBaseDaoImplementsClassType(schema, "<"+entity+">");
	}

	
	
}
